﻿<UserControl x:Class="DomusDotNet.Sbm.Client.SL4noCM.Views.SearchView"
			 xmlns:tk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
			 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:viewmodels="clr-namespace:DomusDotNet.Sbm.Client.SL4noCM.ViewModels"
			 mc:Ignorable="d"
			 d:DesignHeight="300"
			 d:DesignWidth="400">
    <UserControl.DataContext>
        <viewmodels:SearchViewModel></viewmodels:SearchViewModel>
    </UserControl.DataContext>
    <Border Style="{StaticResource GreenPanel}"
		MaxWidth="920" >
        <tk:BusyIndicator IsBusy="{Binding Path=WebRequestExecution}">
            <Grid Margin="20">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>

                <TextBlock FontSize="16">Ricerca</TextBlock>
                <StackPanel Grid.Row="1">
                    <TextBlock>Titolo</TextBlock>
                    <TextBox Text="{Binding Path=TitleFilter, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />

                    <TextBlock>Autore</TextBlock>
                    <TextBox Text="{Binding Path=AuthorFilter, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />

                    <StackPanel Orientation="Horizontal">

                        <StackPanel Width="200">
                            <TextBlock>Pubblicazione: da</TextBlock>
                            <sdk:DatePicker SelectedDate="{Binding Path=PublishDateFromFilter, Mode=TwoWay}" 
								SelectedDateFormat="Short"/>
                        </StackPanel >
                        <StackPanel Width="200"
									Margin="20 0 0 0">
                            <TextBlock>a</TextBlock>
                            <sdk:DatePicker SelectedDate="{Binding Path=PublishDateToFilter, Mode=TwoWay}" 
								SelectedDateFormat="Short"  />
                        </StackPanel>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal"
								HorizontalAlignment="Right">

                        <Button Name="Clear"
								Margin="20 0 0 0"
								Content="Azzera" Command="{Binding Path=ClearCommand}"/>
                        <Button Name="Search"
								Margin="20 0 0 0"
								Content="Cerca" Command="{Binding Path=SearchCommand}"/>
                    </StackPanel>


                </StackPanel>

                <TextBlock Name="ErrorMessage"
						   Style="{StaticResource Error}" Text="{Binding Path=ErrorMessage}" />

                <ListBox Name="Books" 
						 Grid.Row="3" ItemsSource="{Binding Path=Result}" 
                         SelectedItem="{Binding Path=SelectedBook, Mode=TwoWay}" >
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="HorizontalContentAlignment"
                                Value="Stretch" />
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="auto" />
                                </Grid.ColumnDefinitions>
                                <Grid >
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>

                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="2*"></ColumnDefinition>
                                        <ColumnDefinition Width="*"></ColumnDefinition>
                                        <ColumnDefinition Width="*"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>

                                    <TextBlock Grid.ColumnSpan="2"
										   Grid.Row="0"
										   Text="{Binding Path=Title}"
										   Margin="5"
										   FontWeight="ExtraBold" />

                                    <TextBlock Grid.ColumnSpan="2"
										   Grid.Row="1"
										   Text="{Binding Path=Authors, Converter={StaticResource StringEnumeratorToSringConverter}}"
										   FontWeight="Medium"
										   Margin="10 5 5 5" />
                                    <StackPanel Orientation="Horizontal"
											Grid.Column="0"
											Grid.Row="2"
											Margin="15 5 5 5">
                                        <TextBlock Text="Editore:" />
                                        <TextBlock  Text="{Binding Path=Editor}" />
                                    </StackPanel>

                                    <StackPanel Orientation="Horizontal"
											Grid.Column="1"
											Grid.Row="2"
											Grid.ColumnSpan="2"
											Margin="5">
                                        <TextBlock Text="Data Pubblicazione:"
											FontStyle="Italic" />
                                        <TextBlock Text="{Binding Path=PublishDate, StringFormat=\{0:d\}}"
											FontStyle="Italic" />
                                    </StackPanel>

                                    <TextBlock Grid.Column="2"
										   Grid.Row="0"
										   Grid.RowSpan="2"
										   Text="{Binding Path=BookStatus}"
										   VerticalAlignment="Center"
										   HorizontalAlignment="Center" />
                                </Grid>

                                <Button Grid.Column="1"
										Margin="5"
										HorizontalAlignment="Center"
										VerticalAlignment="Center"
										Content="Dettaglio"></Button>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ListBox>


            </Grid>
        </tk:BusyIndicator>
    </Border>
</UserControl>
